package bluetoothcomm;

import java.io.IOException;
import java.io.OutputStream;

import roombacomm.RoombaComm;

public class SerialWriter extends RoombaComm {

    static OutputStream out;

    public SerialWriter ()
    {
    	super();
    }
    
    public SerialWriter ( OutputStream out )
    {

    	SerialWriter.out = out;        
    }
    
    @Override
	public boolean send(byte[] buffer)
	{
		try
        {                
            int i = 0;
            while (i < buffer.length)
            {
                out.write(buffer[i++]);   
            }                
        }
        catch ( IOException e )
        {
            e.printStackTrace();
        }
		return true; 
	}

	@Override
	public String[] listPorts() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean connect(String portid) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void disconnect() {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public boolean send(int b) {
		try
        {                
            out.write(b & 0xff);                                             
        }
        catch ( IOException e )
        {
            e.printStackTrace();
        } 
		return true;
	}

	@Override
	public boolean updateSensors() {
		// TODO Auto-generated method stub
		return false;
	}
}
